<?php

namespace App\Services\User;

use App\Services\ProjectValidate;

/**
 * 当前模块验证规则集合
 *
 * Class ValidateMenu
 */
class ValidateMenu extends ProjectValidate {
    /**
     * 类初始化
     * @param array $initData
     * @return mixed
     */
    public function initValidate($initData = [])
    {
        /*if (!empty($initData['requiredToken'])) {
            $this->rules['token']  = 'required|size:32';
        }*/
    }


    /**
     * @var array 验证规则集合
     */
    public $rules = [
        'menu_cate_id'   => 'int|min:1',
        'name'           => 'alpha_num|min:2|max:20',
        //'name_cn'        => 'regex:/^{.*}$/|alpha_num|min:2|max:20',  ['chsAlphaNum', 'length'=>'2,20'],
        'name_cn'        => 'min:2|max:20', 
        'type'           => 'in:menu,button,nav',
        'url'            => 'url',
        'merge_auth'     => 'min:4|max:128',
        'auth_data'      => 'regex:/^{.*}$/',
        'auth_id'        => 'int|min:1',
        'pid'            => 'int|min:1',
        'level'          => 'int|min:2',
        'id'             => 'int|min:1',
        'menu_id'        => 'int|min:1',
        'role_id'        =>  'int|min:1',
        'parent_menu_id' => 'int|min:1',
        'role_ids'       => 'regex:/^(\d)+(,\d+)*'

    ];


    

    /**
     * @var array 当前验证错误信息
     */
    public $messages = [
    ];

    /**
     * @var array 上面规则中定义的 key 的名字
     */
    public $attributes = [
        'id'        => 'ID',
        'create_ip' =>  '用户IP'
    ];

}